﻿Partial Public Class encMedicoGeriatra1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Session("usuarioId") Is Nothing Then
                Response.Redirect("loguin.aspx")
            End If
            If Not Session("profesionId") Is Nothing Then
                If Permisos.Validar(Session("profesionId").ToString, 4) = False Then
                    Response.Redirect("Denied.aspx")
                End If
            Else
                Response.Redirect("Denied.aspx")
            End If
            If Not IsPostBack Then
                lbprofesion.Text = Session("profesion").ToString()
                lbnombre.Text = Session("nombre").ToString()
                Dim TablaId = Request.QueryString.Get("medicoId")
                If TablaId <> "" Then
                    Consulta_Registro(TablaId, sender, e)
                    If Request.QueryString.Get("medicoId") <> "" Then
                        Msgbox_Web.CreateMessageAlertInUpdatePanel(UpdatePanel1, "fnCargaEdicion();")
                    End If
                End If
            End If
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

    Public Sub Consulta_Registro(ByVal Id As Integer, ByVal sender As Object, ByVal e As EventArgs)
        On Error GoTo errores
        Dim Docmd As New DoCmd, reader As System.Data.SqlClient.SqlDataReader
        Dim Qry As String
        Dim camp As Integer
        Qry = "SELECT     med.*, par.primerNombre + ' ' + par.segundoNombre + ' ' + par.primerApellido + ' ' + par.segundoApellido AS NombreCompleto, YEAR({ fn NOW() }) - YEAR(par.fechaNacimiento) AS Edad,par.sexo FROM medicoGeriatra AS med INNER JOIN participantes AS par ON par.participanteId = med.participantesId where med.medicoId = " & Id
        Docmd.Conectar()
        reader = Docmd.Read_SQL(Qry)
        While reader.Read
            camp = reader.FieldCount
            For i = 0 To camp - 1
                On Error Resume Next
                If Page.Form.FindControl(reader.GetName(i)).ID <> "" Then
                    Asigna_control(Page.Form.FindControl(reader.GetName(i)), reader(i).ToString().Trim)
                End If
            Next
        End While
        reader.Close()
        Docmd.Desconectar()
        Exit Sub
errores:
        Response.Write(Err.Description)
    End Sub

    Private Sub Asigna_control(ByVal Objeto As Object, ByRef valor As String)
        Select Case Objeto.GetType.Name
            Case "HiddenField"
                If valor <> "" Then
                    Objeto.value = valor
                Else
                    Objeto.value = ""
                End If
            Case "TextBox"
                If valor <> "" Then
                    Objeto.text = valor
                Else
                    Objeto.text = ""
                End If
            Case "CheckBox"
                If valor = "Si" Then
                    Objeto.Checked = True
                Else
                    Objeto.Checked = False
                End If
            Case "RadioButtonList"
                If valor <> "" Then
                    If valor = "True" Then
                        Objeto.SelectedValue = 1
                    ElseIf valor = "False" Then
                        Objeto.SelectedValue = 0
                    Else
                        Objeto.SelectedValue = valor
                    End If
                Else
                    Objeto.SelectedIndex = -1
                End If
            Case "DropDownList"
                If valor <> "" Then
                    Objeto.SelectedValue = Objeto.Items.FindByValue(valor.Trim).Value
                Else
                    Objeto.SelectedIndex = -1
                End If
        End Select
    End Sub

    Private Sub cargacombos(ByVal participanteId As Integer)
        Try
            Dim docmd As New Sql_Server
            docmd.Conectar()
            docmd.Combo = cboUltRegistros
            docmd.Listar_Combo("SELECT TOP (50) med.medicoId, CAST(med.fechaCreo AS varchar) + '->' + par.primerNombre + ' ' + CASE WHEN par.segundoNombre IS NULL THEN '' ELSE par.segundoNombre END + '  ' + par.primerApellido + ' ' + CASE WHEN par.segundoApellido IS NULL THEN '' ELSE par.segundoApellido END AS Nombre FROM medicoGeriatra AS med INNER JOIN participantes AS par ON par.participanteId = med.participantesId WHERE (med.participantesId = " + participanteId.ToString + ") ORDER BY med.fechaCreo DESC")
            docmd.Desconectar()
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

    Protected Sub btnConsulta_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnConsulta.Click
        Dim where As String
        where = " 1 = 1"
        If cbotipDocumento.SelectedValue.Trim <> "-1" Then
            where = where + " and tipoDocumento = '" + cbotipDocumento.SelectedValue.Trim + "'"
        End If
        If txtDocumento.Text.Trim <> "" Then
            where = where + " and documento = '" + txtDocumento.Text.Trim + "'"
        End If
        If conPrinombre.Text.Trim <> "" Then
            where = where + " and primerNombre like '%" + conPrinombre.Text.Trim + "%'"
        End If
        If conSegnombre.Text.Trim <> "" Then
            where = where + " and segundoNombre like '%" + conSegnombre.Text.Trim + "%'"
        End If
        If conPriApe.Text.Trim <> "" Then
            where = where + " and primerApellido like '%" + conPriApe.Text.Trim + "%'"
        End If
        If conSegApe.Text.Trim <> "" Then
            where = where + " and segundoApellido like '%" + conSegApe.Text.Trim + "%'"
        End If
        SqlDataSource1.FilterExpression = where
        SqlDataSource1.DataBind()
    End Sub

    Protected Sub btnGuardar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGuardar.Click
        If Page.IsValid = True Then
            Dim modelo As New DataClasses1DataContext()
            Dim cstype As Type = Page.GetType()
            Dim cs As ClientScriptManager = Page.ClientScript
            Dim sb As StringBuilder = New StringBuilder()
            If IsNumeric(medicoId.Value.Trim) Then
                'Se trata de una edicion
                Dim ClmedGeriatra = (From med In modelo.medicoGeriatras Where med.medicoId.Equals(medicoId.Value.Trim) Select med).Single()
                ClmedGeriatra.sienteSalud = sienteSalud.SelectedValue.Trim
                ClmedGeriatra.consideraSalud = consideraSalud.SelectedValue.Trim
                ClmedGeriatra.comparaSalud = comparaSalud.SelectedValue.Trim
                If cardioHTA.Checked Then
                    ClmedGeriatra.cardioHTA = "Si"
                Else
                    ClmedGeriatra.cardioHTA = "No"
                End If
                If cardioIMA.Checked Then
                    ClmedGeriatra.cardioIMA = "Si"
                Else
                    ClmedGeriatra.cardioIMA = "No"
                End If
                If cardioInsuCar.Checked Then
                    ClmedGeriatra.cardioInsuCar = "Si"
                Else
                    ClmedGeriatra.cardioInsuCar = "No"
                End If
                If cardioAngPecho.Checked Then
                    ClmedGeriatra.cardioAngPecho = "Si"
                Else
                    ClmedGeriatra.cardioAngPecho = "No"
                End If
                'sss
                If pulmoEPOC.Checked Then
                    ClmedGeriatra.pulmoEPOC = "Si"
                Else
                    ClmedGeriatra.pulmoEPOC = "No"
                End If
                If pulmoTBC.Checked Then
                    ClmedGeriatra.pulmoTBC = "Si"
                Else
                    ClmedGeriatra.pulmoTBC = "No"
                End If
                If pulmoNeomoco.Checked Then
                    ClmedGeriatra.pulmoNeomoco = "Si"
                Else
                    ClmedGeriatra.pulmoNeomoco = "No"
                End If
                If pulmoNeumonia.Checked Then
                    ClmedGeriatra.pulmoNeumonia = "Si"
                Else
                    ClmedGeriatra.pulmoNeumonia = "No"
                End If
                If pulmoAsma.Checked Then
                    ClmedGeriatra.pulmoAsma = "Si"
                Else
                    ClmedGeriatra.pulmoAsma = "No"
                End If
                ClmedGeriatra.pulmoOto = pulmoOto.Text.Trim
                If osteoOsteoar.Checked Then
                    ClmedGeriatra.osteoOsteoar = "Si"
                Else
                    ClmedGeriatra.osteoOsteoar = "No"
                End If
                If osteoAr.Checked Then
                    ClmedGeriatra.osteoAr = "Si"
                Else
                    ClmedGeriatra.osteoAr = "No"
                End If
                If osteoOsteopo.Checked Then
                    ClmedGeriatra.osteoOsteopo = "Si"
                Else
                    ClmedGeriatra.osteoOsteopo = "No"
                End If
                ClmedGeriatra.osteoOtros = osteoOtros.Text.Trim
                If sisEndoDieabetesMelli.Checked Then
                    ClmedGeriatra.sisEndoDieabetesMelli = "Si"
                Else
                    ClmedGeriatra.sisEndoDieabetesMelli = "No"
                End If
                If sisEndoHipo.Checked Then
                    ClmedGeriatra.sisEndoHipo = "Si"
                Else
                    ClmedGeriatra.sisEndoHipo = "No"
                End If
                If SisEndoDislipo.Checked Then
                    ClmedGeriatra.sisEndoDislipo = "Si"
                Else
                    ClmedGeriatra.sisEndoDislipo = "No"
                End If
                If sisEndoHiperuri.Checked Then
                    ClmedGeriatra.sisEndoHiperuri = "Si"
                Else
                    ClmedGeriatra.sisEndoHiperuri = "No"
                End If
                ClmedGeriatra.sisEndoOtros = SisEndoOtros.Text.Trim
                If tractoHernia.Checked Then
                    ClmedGeriatra.tractoHernia = "Si"
                Else
                    ClmedGeriatra.tractoHernia = "No"
                End If
                If tractoAcido.Checked Then
                    ClmedGeriatra.tractoAcido = "Si"
                Else
                    ClmedGeriatra.tractoAcido = "No"
                End If
                If tractoUlceraGastrica.Checked Then
                    ClmedGeriatra.tractoUlceraGastrica = "Si"
                Else
                    ClmedGeriatra.tractoUlceraGastrica = "No"
                End If
                If tractoColon.Checked Then
                    ClmedGeriatra.tractoColon = "Si"
                Else
                    ClmedGeriatra.tractoColon = "No"
                End If
                If tractoSangradoAlto.Checked Then
                    ClmedGeriatra.tractoSangradoAlto = "Si"
                Else
                    ClmedGeriatra.tractoSangradoAlto = "No"
                End If
                If tractoSangradoBajo.Checked Then
                    ClmedGeriatra.tractoSangradoBajo = "Si"
                Else
                    ClmedGeriatra.tractoSangradoBajo = "No"
                End If
                If tractoUlceraDuodenal.Checked Then
                    ClmedGeriatra.tractoUlceraDuodenal = "Si"
                Else
                    ClmedGeriatra.tractoUlceraDuodenal = "No"
                End If
                If tractoCosti.Checked Then
                    ClmedGeriatra.tractoCosti = "Si"
                Else
                    ClmedGeriatra.tractoCosti = "No"
                End If
                ClmedGeriatra.tractoOtros = tractoOtros.Text.Trim
                If neuroECVtrombico.Checked Then
                    ClmedGeriatra.neuroECVtrombico = "Si"
                Else
                    ClmedGeriatra.neuroECVtrombico = "No"
                End If
                If neuroECVHemo.Checked Then
                    ClmedGeriatra.neuroECVHemo = "Si"
                Else
                    ClmedGeriatra.neuroECVHemo = "No"
                End If
                If neuroECVEmbo.Checked Then
                    ClmedGeriatra.neuroECVEmbo = "Si"
                Else
                    ClmedGeriatra.neuroECVEmbo = "No"
                End If
                If neuroACV.Checked Then
                    ClmedGeriatra.neuroACV = "Si"
                Else
                    ClmedGeriatra.neuroACV = "No"
                End If
                If neuroParkinson.Checked Then
                    ClmedGeriatra.neuroParkinson = "Si"
                Else
                    ClmedGeriatra.neuroParkinson = "No"
                End If
                If neuroNeuropatias.Checked Then
                    ClmedGeriatra.neuroNeuropatias = "Si"
                Else
                    ClmedGeriatra.neuroNeuropatias = "No"
                End If
                If neuroSxVerti.Checked Then
                    ClmedGeriatra.neuroSxVerti = "Si"
                Else
                    ClmedGeriatra.neuroSxVerti = "No"
                End If
                If neuroDemencia.Checked Then
                    ClmedGeriatra.neuroDemencia = "Si"
                Else
                    ClmedGeriatra.neuroDemencia = "No"
                End If
                If neuroMareos.Checked Then
                    ClmedGeriatra.neuroMareos = "Si"
                Else
                    ClmedGeriatra.neuroMareos = "No"
                End If
                If neuroSxConfucional.Checked Then
                    ClmedGeriatra.neuroSxConfucional = "Si"
                Else
                    ClmedGeriatra.neuroSxConfucional = "No"
                End If
                If neuroITC.Checked Then
                    ClmedGeriatra.neuroITC = "Si"
                Else
                    ClmedGeriatra.neuroITC = "No"
                End If
                ClmedGeriatra.neuroOtros = neuroOtros.Text.Trim
                If neoCamama.Checked Then
                    ClmedGeriatra.neoCamama = "Si"
                Else
                    ClmedGeriatra.neoCamama = "No"
                End If
                If neoCaCerviz.Checked Then
                    ClmedGeriatra.neoCaCerviz = "Si"
                Else
                    ClmedGeriatra.neoCaCerviz = "No"
                End If
                If neoCaProstata.Checked Then
                    ClmedGeriatra.neoCaProstata = "Si"
                Else
                    ClmedGeriatra.neoCaProstata = "No"
                End If
                If neoCaPulmon.Checked Then
                    ClmedGeriatra.neoCaPulmon = "Si"
                Else
                    ClmedGeriatra.neoCaPulmon = "No"
                End If
                If neoCaTiroides.Checked Then
                    ClmedGeriatra.neoCaTiroides = "Si"
                Else
                    ClmedGeriatra.neoCaTiroides = "No"
                End If
                If neoBasocelular.Checked Then
                    ClmedGeriatra.neoBasocelular = "Si"
                Else
                    ClmedGeriatra.neoBasocelular = "No"
                End If
                If neoCaEspino.Checked Then
                    ClmedGeriatra.neoCaEspino = "Si"
                Else
                    ClmedGeriatra.neoCaEspino = "No"
                End If
                If noeMelanoma.Checked Then
                    ClmedGeriatra.noeMelanoma = "Si"
                Else
                    ClmedGeriatra.noeMelanoma = "No"
                End If
                If neoCaGastrico.Checked Then
                    ClmedGeriatra.neoCaGastrico = "Si"
                Else
                    ClmedGeriatra.neoCaGastrico = "No"
                End If
                If neoCaColon.Checked Then
                    ClmedGeriatra.neoCaColon = "Si"
                Else
                    ClmedGeriatra.neoCaColon = "No"
                End If
                If otroVasArterial.Checked Then
                    ClmedGeriatra.otroVasArterial = "Si"
                Else
                    ClmedGeriatra.otroVasArterial = "No"
                End If
                If otroVasVenosa.Checked Then
                    ClmedGeriatra.otroVasVenosa = "Si"
                Else
                    ClmedGeriatra.otroVasVenosa = "No"
                End If
                If otroSincope.Checked Then
                    ClmedGeriatra.otroSincope = "Si"
                Else
                    ClmedGeriatra.otroSincope = "No"
                End If
                If otrosAnemias.Checked Then
                    ClmedGeriatra.otroAnemias = "Si"
                Else
                    ClmedGeriatra.otroAnemias = "No"
                End If
                If otroSxInmovilizacion.Checked Then
                    ClmedGeriatra.otroSxInmovilizacion = "Si"
                Else
                    ClmedGeriatra.otroSxInmovilizacion = "No"
                End If
                ClmedGeriatra.otroOtros = otrosOtros.Text.Trim
                'Antecedentes Quirurgicos
                ClmedGeriatra.antecendentesQx = antecendentesQx.Text.Trim
                If txtPestana.Value.Trim >= 2 Then
                    'Antecedentes Genitourinarios
                    If gesta.Text.Trim = "" Then
                        ClmedGeriatra.gesta = 0
                    Else
                        ClmedGeriatra.gesta = gesta.Text.Trim
                    End If
                    If para.Text.Trim = "" Then
                        ClmedGeriatra.para = 0
                    Else
                        ClmedGeriatra.para = para.Text.Trim
                    End If
                    If abortos.Text.Trim = "" Then
                        ClmedGeriatra.abortos = 0
                    Else
                        ClmedGeriatra.abortos = abortos.Text.Trim
                    End If
                    If vivos.Text.Trim = "" Then
                        ClmedGeriatra.vivos = 0
                    Else
                        ClmedGeriatra.vivos = vivos.Text.Trim
                    End If
                    If edadFUM.Text.Trim = "" Then
                        ClmedGeriatra.edadFUM = 0
                    Else
                        ClmedGeriatra.edadFUM = edadFUM.Text.Trim
                    End If
                    If ultimaCitologia.Text.Trim = "" Then
                        ClmedGeriatra.ultimaCitologia = 0
                    Else
                        ClmedGeriatra.ultimaCitologia = ultimaCitologia.Text.Trim
                    End If
                    ClmedGeriatra.resultCitologia = resultCitologia.SelectedValue.Trim
                    ClmedGeriatra.puritoGen = puritoGen.SelectedValue.Trim
                    ClmedGeriatra.flujos = flujos.SelectedValue.Trim
                    ClmedGeriatra.protastatismo = protastatismo.SelectedValue.Trim
                    ClmedGeriatra.especifiqueProtasta = especifiqueProtasta.Text.Trim
                    ClmedGeriatra.inconDiurnaAgu = inconDiurnaAgu.SelectedValue.Trim
                    ClmedGeriatra.inconDiurnaCro = inconDiurnaCro.SelectedValue.Trim
                    ClmedGeriatra.inconDiurnaOca = inconDiurnaOca.SelectedValue.Trim
                    ClmedGeriatra.inconNocturnaAgu = inconNocturnaAgu.SelectedValue.Trim
                    ClmedGeriatra.inconNocturnaCro = inconNocturnaCro.SelectedValue.Trim
                    ClmedGeriatra.inconNocturnaOca = inconNocturnaOca.SelectedValue.Trim
                    ClmedGeriatra.habIntesFrec = habIntesFrec.Text.Trim
                    ClmedGeriatra.enfTransmSexual = enfTransmSexual.SelectedValue.Trim
                    ClmedGeriatra.espEnfTransmSexual = espEnfTransmSexual.Text.Trim
                    ClmedGeriatra.relacionesSexuales = relacionesSexuales.SelectedValue.Trim
                    ClmedGeriatra.espRelacionesSexuales = espRelacionesSexuales.Text.Trim
                    ClmedGeriatra.hisFarmaPresAuto = hisFarmaPresAuto.SelectedValue.Trim
                    ClmedGeriatra.hisFarmaPresAutoActual = hisFarmaPresAutoActual.Text.Trim
                    ClmedGeriatra.hisFarmaPresAutoPrevia = hisFarmaPresAutoPrevia.Text.Trim
                End If 'fin Antecedentes Genitourinarios
                If txtPestana.Value.Trim >= 3 Then
                    'Historia Farmacologica
                    ClmedGeriatra.hisFarmaPresMed = hisFarmaPresMed.SelectedValue.Trim
                    ClmedGeriatra.hisFarmaPresMedActual = hisFarmaPresMedActual.Text.Trim
                    ClmedGeriatra.hisFarmaPresMedPrevia = hisFarmaPresMedPrevia.Text.Trim
                    ClmedGeriatra.difTrata = difTrata.SelectedValue.Trim
                    ClmedGeriatra.difTrataCausa = difTrataCausa.Text.Trim
                    ClmedGeriatra.difTrataEcono = difTrataEcono.SelectedValue.Trim
                    ClmedGeriatra.difTrataFisico = difTrataFisico.SelectedValue.Trim
                    ClmedGeriatra.difTrataCognitivo = difTrataCognitivo.SelectedValue.Trim
                    ClmedGeriatra.difTrataRAM = difTrataRAM.SelectedValue.Trim
                End If
                If txtPestana.Value.Trim >= 4 Then
                    'antecendentes heredo familiares
                    ClmedGeriatra.heredaHTA = heredaHTA.SelectedValue.Trim
                    ClmedGeriatra.heredaAsma = heredaAsma.SelectedValue.Trim
                    ClmedGeriatra.heredaDemencia = heredaDemencia.SelectedValue.Trim
                    ClmedGeriatra.heredaObesidad = heredaObesidad.SelectedValue.Trim
                    ClmedGeriatra.heredaEpilepsia = heredaEpilepsia.SelectedValue.Trim
                    ClmedGeriatra.heredaDiabetes = heredaDiabetes.SelectedValue.Trim
                    ClmedGeriatra.heredaReumatica = heredaReumatica.SelectedValue.Trim
                    ClmedGeriatra.heredaDepresion = heredaDepresion.SelectedValue.Trim
                    ClmedGeriatra.heredaRenal = heredaRenal.SelectedValue.Trim
                    ClmedGeriatra.heredaTBC = heredaTBC.SelectedValue.Trim
                    ClmedGeriatra.heredaCancer = heredaCancer.SelectedValue.Trim
                    ClmedGeriatra.heredaOtros = heredaOtros.Text.Trim
                End If
                If txtPestana.Value.Trim >= 5 Then
                    'Habitos
                    ClmedGeriatra.habitoFumo = habitoFumo.SelectedValue.Trim
                    ClmedGeriatra.habitoFuma = habitoFuma.SelectedValue.Trim
                    If añosFumando.Text.Trim = "" Then
                        ClmedGeriatra.añosFumando = 0
                    Else
                        ClmedGeriatra.añosFumando = añosFumando.Text.Trim
                    End If
                    If paquetesDia.Text.Trim = "" Then
                        ClmedGeriatra.paquetesDia = 0
                    Else
                        ClmedGeriatra.paquetesDia = paquetesDia.Text.Trim
                    End If
                    ClmedGeriatra.habitoToma = habitoToma.SelectedValue.Trim
                    ClmedGeriatra.frecuenciaTomaDia = frecuenciaTomaDia.SelectedValue.Trim
                    ClmedGeriatra.frecuenciaTomaSemana = frecuenciaTomaSemana.SelectedValue.Trim
                    ClmedGeriatra.frecuenciaTomaMes = frecuenciaTomaMes.SelectedValue.Trim
                    'Historia Psiquiatrica
                    ClmedGeriatra.psiquiDepresion = psiquiDepresion.SelectedValue.Trim
                    ClmedGeriatra.psiquiEnfermedad = psiquiEnfermedad.SelectedValue.Trim
                    ClmedGeriatra.psiquiEnfermedadHospitalizacion = psiquiEnfermedadHospitalizacion.SelectedValue.Trim
                    'Motivo de Consulta y Enfermedad Actual
                    ClmedGeriatra.motivoConsulta = motivoConsulta.Text.Trim
                    'Examen Fisico
                    ClmedGeriatra.tenArterialAltaN = tenArterialAltaN.Text.Trim
                    ClmedGeriatra.tenArterialAltaD = tenArterialAltaD.Text.Trim
                    ClmedGeriatra.tenArterialBajaN = tenArterialBajaN.Text.Trim
                    ClmedGeriatra.tenArterialBajaD = tenArterialBajaD.Text.Trim
                    ClmedGeriatra.tenArterialToma = tenArterialToma.SelectedValue.Trim
                    ClmedGeriatra.temperatura = temperatura.Text.Trim
                    ClmedGeriatra.frecRespiratoria = frecRespiratoria.Text.Trim
                    ClmedGeriatra.frecCardiaca = frecCardiaca.Text.Trim
                    ClmedGeriatra.pulso = pulso.Text.Trim
                    ClmedGeriatra.apariencia = apariencia.SelectedValue.Trim
                    ClmedGeriatra.hidratacion = hidratacion.SelectedValue.Trim
                    ClmedGeriatra.impreDiagnostica = impreDiagnostica.Text.Trim
                    ClmedGeriatra.recomendaciones = recomendaciones.Text.Trim
                End If
                modelo.SubmitChanges()
                'medicoId.Value = med
                If txtContinua.Value.Trim = "Si" Then
                    Msgbox_Web.CreateMessageAlertInUpdatePanel(UpdatePanel1, "alert('Se ha guardado correctamente');")
                Else
                    Msgbox_Web.CreateMessageAlertInUpdatePanel(UpdatePanel1, "alert('Se ha guardado correctamente');window.location = 'encMedicoGeriatra.aspx'")
                End If
            Else
                'Se trata de un nuevo registro
                Dim ClmedGeriatra As New medicoGeriatra
                If txtParticipanteId.Value.Trim = "" Then
                    Exit Sub
                End If
                ClmedGeriatra.usuario_id = Session("usuarioId").ToString
                ClmedGeriatra.participantesId = txtParticipanteId.Value.Trim
                ClmedGeriatra.sienteSalud = sienteSalud.SelectedValue.Trim
                ClmedGeriatra.consideraSalud = consideraSalud.SelectedValue.Trim
                ClmedGeriatra.comparaSalud = comparaSalud.SelectedValue.Trim
                If cardioHTA.Checked Then
                    ClmedGeriatra.cardioHTA = "Si"
                Else
                    ClmedGeriatra.cardioHTA = "No"
                End If
                If cardioIMA.Checked Then
                    ClmedGeriatra.cardioIMA = "Si"
                Else
                    ClmedGeriatra.cardioIMA = "No"
                End If
                If cardioInsuCar.Checked Then
                    ClmedGeriatra.cardioInsuCar = "Si"
                Else
                    ClmedGeriatra.cardioInsuCar = "No"
                End If
                If cardioAngPecho.Checked Then
                    ClmedGeriatra.cardioAngPecho = "Si"
                Else
                    ClmedGeriatra.cardioAngPecho = "No"
                End If
                'sss
                If pulmoEPOC.Checked Then
                    ClmedGeriatra.pulmoEPOC = "Si"
                Else
                    ClmedGeriatra.pulmoEPOC = "No"
                End If
                If pulmoTBC.Checked Then
                    ClmedGeriatra.pulmoTBC = "Si"
                Else
                    ClmedGeriatra.pulmoTBC = "No"
                End If
                If pulmoNeomoco.Checked Then
                    ClmedGeriatra.pulmoNeomoco = "Si"
                Else
                    ClmedGeriatra.pulmoNeomoco = "No"
                End If
                If pulmoNeumonia.Checked Then
                    ClmedGeriatra.pulmoNeumonia = "Si"
                Else
                    ClmedGeriatra.pulmoNeumonia = "No"
                End If
                If pulmoAsma.Checked Then
                    ClmedGeriatra.pulmoAsma = "Si"
                Else
                    ClmedGeriatra.pulmoAsma = "No"
                End If
                ClmedGeriatra.pulmoOto = pulmoOto.Text.Trim
                If osteoOsteoar.Checked Then
                    ClmedGeriatra.osteoOsteoar = "Si"
                Else
                    ClmedGeriatra.osteoOsteoar = "No"
                End If
                If osteoAr.Checked Then
                    ClmedGeriatra.osteoAr = "Si"
                Else
                    ClmedGeriatra.osteoAr = "No"
                End If
                If osteoOsteopo.Checked Then
                    ClmedGeriatra.osteoOsteopo = "Si"
                Else
                    ClmedGeriatra.osteoOsteopo = "No"
                End If
                ClmedGeriatra.osteoOtros = osteoOtros.Text.Trim
                If sisEndoDieabetesMelli.Checked Then
                    ClmedGeriatra.sisEndoDieabetesMelli = "Si"
                Else
                    ClmedGeriatra.sisEndoDieabetesMelli = "No"
                End If
                If sisEndoHipo.Checked Then
                    ClmedGeriatra.sisEndoHipo = "Si"
                Else
                    ClmedGeriatra.sisEndoHipo = "No"
                End If
                If SisEndoDislipo.Checked Then
                    ClmedGeriatra.sisEndoDislipo = "Si"
                Else
                    ClmedGeriatra.sisEndoDislipo = "No"
                End If
                If sisEndoHiperuri.Checked Then
                    ClmedGeriatra.sisEndoHiperuri = "Si"
                Else
                    ClmedGeriatra.sisEndoHiperuri = "No"
                End If
                ClmedGeriatra.sisEndoOtros = SisEndoOtros.Text.Trim
                If tractoHernia.Checked Then
                    ClmedGeriatra.tractoHernia = "Si"
                Else
                    ClmedGeriatra.tractoHernia = "No"
                End If
                If tractoAcido.Checked Then
                    ClmedGeriatra.tractoAcido = "Si"
                Else
                    ClmedGeriatra.tractoAcido = "No"
                End If
                If tractoUlceraGastrica.Checked Then
                    ClmedGeriatra.tractoUlceraGastrica = "Si"
                Else
                    ClmedGeriatra.tractoUlceraGastrica = "No"
                End If
                If tractoColon.Checked Then
                    ClmedGeriatra.tractoColon = "Si"
                Else
                    ClmedGeriatra.tractoColon = "No"
                End If
                If tractoSangradoAlto.Checked Then
                    ClmedGeriatra.tractoSangradoAlto = "Si"
                Else
                    ClmedGeriatra.tractoSangradoAlto = "No"
                End If
                If tractoSangradoBajo.Checked Then
                    ClmedGeriatra.tractoSangradoBajo = "Si"
                Else
                    ClmedGeriatra.tractoSangradoBajo = "No"
                End If
                If tractoUlceraDuodenal.Checked Then
                    ClmedGeriatra.tractoUlceraDuodenal = "Si"
                Else
                    ClmedGeriatra.tractoUlceraDuodenal = "No"
                End If
                If tractoCosti.Checked Then
                    ClmedGeriatra.tractoCosti = "Si"
                Else
                    ClmedGeriatra.tractoCosti = "No"
                End If
                ClmedGeriatra.tractoOtros = tractoOtros.Text.Trim
                If neuroECVtrombico.Checked Then
                    ClmedGeriatra.neuroECVtrombico = "Si"
                Else
                    ClmedGeriatra.neuroECVtrombico = "No"
                End If
                If neuroECVHemo.Checked Then
                    ClmedGeriatra.neuroECVHemo = "Si"
                Else
                    ClmedGeriatra.neuroECVHemo = "No"
                End If
                If neuroECVEmbo.Checked Then
                    ClmedGeriatra.neuroECVEmbo = "Si"
                Else
                    ClmedGeriatra.neuroECVEmbo = "No"
                End If
                If neuroACV.Checked Then
                    ClmedGeriatra.neuroACV = "Si"
                Else
                    ClmedGeriatra.neuroACV = "No"
                End If
                If neuroParkinson.Checked Then
                    ClmedGeriatra.neuroParkinson = "Si"
                Else
                    ClmedGeriatra.neuroParkinson = "No"
                End If
                If neuroNeuropatias.Checked Then
                    ClmedGeriatra.neuroNeuropatias = "Si"
                Else
                    ClmedGeriatra.neuroNeuropatias = "No"
                End If
                If neuroSxVerti.Checked Then
                    ClmedGeriatra.neuroSxVerti = "Si"
                Else
                    ClmedGeriatra.neuroSxVerti = "No"
                End If
                If neuroDemencia.Checked Then
                    ClmedGeriatra.neuroDemencia = "Si"
                Else
                    ClmedGeriatra.neuroDemencia = "No"
                End If
                If neuroMareos.Checked Then
                    ClmedGeriatra.neuroMareos = "Si"
                Else
                    ClmedGeriatra.neuroMareos = "No"
                End If
                If neuroSxConfucional.Checked Then
                    ClmedGeriatra.neuroSxConfucional = "Si"
                Else
                    ClmedGeriatra.neuroSxConfucional = "No"
                End If
                If neuroITC.Checked Then
                    ClmedGeriatra.neuroITC = "Si"
                Else
                    ClmedGeriatra.neuroITC = "No"
                End If
                ClmedGeriatra.neuroOtros = neuroOtros.Text.Trim
                If neoCamama.Checked Then
                    ClmedGeriatra.neoCamama = "Si"
                Else
                    ClmedGeriatra.neoCamama = "No"
                End If
                If neoCaCerviz.Checked Then
                    ClmedGeriatra.neoCaCerviz = "Si"
                Else
                    ClmedGeriatra.neoCaCerviz = "No"
                End If
                If neoCaProstata.Checked Then
                    ClmedGeriatra.neoCaProstata = "Si"
                Else
                    ClmedGeriatra.neoCaProstata = "No"
                End If
                If neoCaPulmon.Checked Then
                    ClmedGeriatra.neoCaPulmon = "Si"
                Else
                    ClmedGeriatra.neoCaPulmon = "No"
                End If
                If neoCaTiroides.Checked Then
                    ClmedGeriatra.neoCaTiroides = "Si"
                Else
                    ClmedGeriatra.neoCaTiroides = "No"
                End If
                If neoBasocelular.Checked Then
                    ClmedGeriatra.neoBasocelular = "Si"
                Else
                    ClmedGeriatra.neoBasocelular = "No"
                End If
                If neoCaEspino.Checked Then
                    ClmedGeriatra.neoCaEspino = "Si"
                Else
                    ClmedGeriatra.neoCaEspino = "No"
                End If
                If noeMelanoma.Checked Then
                    ClmedGeriatra.noeMelanoma = "Si"
                Else
                    ClmedGeriatra.noeMelanoma = "No"
                End If
                If neoCaGastrico.Checked Then
                    ClmedGeriatra.neoCaGastrico = "Si"
                Else
                    ClmedGeriatra.neoCaGastrico = "No"
                End If
                If neoCaColon.Checked Then
                    ClmedGeriatra.neoCaColon = "Si"
                Else
                    ClmedGeriatra.neoCaColon = "No"
                End If
                If otroVasArterial.Checked Then
                    ClmedGeriatra.otroVasArterial = "Si"
                Else
                    ClmedGeriatra.otroVasArterial = "No"
                End If
                If otroVasVenosa.Checked Then
                    ClmedGeriatra.otroVasVenosa = "Si"
                Else
                    ClmedGeriatra.otroVasVenosa = "No"
                End If
                If otroSincope.Checked Then
                    ClmedGeriatra.otroSincope = "Si"
                Else
                    ClmedGeriatra.otroSincope = "No"
                End If
                If otrosAnemias.Checked Then
                    ClmedGeriatra.otroAnemias = "Si"
                Else
                    ClmedGeriatra.otroAnemias = "No"
                End If
                If otroSxInmovilizacion.Checked Then
                    ClmedGeriatra.otroSxInmovilizacion = "Si"
                Else
                    ClmedGeriatra.otroSxInmovilizacion = "No"
                End If
                ClmedGeriatra.otroOtros = otrosOtros.Text.Trim
                ClmedGeriatra.fechaCreo = DateTime.Now
                'Antecedentes Quirurgicos
                ClmedGeriatra.antecendentesQx = antecendentesQx.Text.Trim
                If txtPestana.Value.Trim >= 2 Then
                    'Antecedentes Genitourinarios
                    If gesta.Text.Trim = "" Then
                        ClmedGeriatra.gesta = 0
                    Else
                        ClmedGeriatra.gesta = gesta.Text.Trim
                    End If
                    If para.Text.Trim = "" Then
                        ClmedGeriatra.para = 0
                    Else
                        ClmedGeriatra.para = para.Text.Trim
                    End If
                    If abortos.Text.Trim = "" Then
                        ClmedGeriatra.abortos = 0
                    Else
                        ClmedGeriatra.abortos = abortos.Text.Trim
                    End If
                    If vivos.Text.Trim = "" Then
                        ClmedGeriatra.vivos = 0
                    Else
                        ClmedGeriatra.vivos = vivos.Text.Trim
                    End If
                    If edadFUM.Text.Trim = "" Then
                        ClmedGeriatra.edadFUM = 0
                    Else
                        ClmedGeriatra.edadFUM = edadFUM.Text.Trim
                    End If
                    If ultimaCitologia.Text.Trim = "" Then
                        ClmedGeriatra.ultimaCitologia = 0
                    Else
                        ClmedGeriatra.ultimaCitologia = ultimaCitologia.Text.Trim
                    End If
                    ClmedGeriatra.resultCitologia = resultCitologia.SelectedValue.Trim
                    ClmedGeriatra.puritoGen = puritoGen.SelectedValue.Trim
                    ClmedGeriatra.flujos = flujos.SelectedValue.Trim
                    ClmedGeriatra.protastatismo = protastatismo.SelectedValue.Trim
                    ClmedGeriatra.especifiqueProtasta = especifiqueProtasta.Text.Trim
                    ClmedGeriatra.inconDiurnaAgu = inconDiurnaAgu.SelectedValue.Trim
                    ClmedGeriatra.inconDiurnaCro = inconDiurnaCro.SelectedValue.Trim
                    ClmedGeriatra.inconDiurnaOca = inconDiurnaOca.SelectedValue.Trim
                    ClmedGeriatra.inconNocturnaAgu = inconNocturnaAgu.SelectedValue.Trim
                    ClmedGeriatra.inconNocturnaCro = inconNocturnaCro.SelectedValue.Trim
                    ClmedGeriatra.inconNocturnaOca = inconNocturnaOca.SelectedValue.Trim
                    ClmedGeriatra.habIntesFrec = habIntesFrec.Text.Trim
                    ClmedGeriatra.enfTransmSexual = enfTransmSexual.SelectedValue.Trim
                    ClmedGeriatra.espEnfTransmSexual = espEnfTransmSexual.Text.Trim
                    ClmedGeriatra.relacionesSexuales = relacionesSexuales.SelectedValue.Trim
                    ClmedGeriatra.espRelacionesSexuales = espRelacionesSexuales.Text.Trim
                    ClmedGeriatra.hisFarmaPresAuto = hisFarmaPresAuto.SelectedValue.Trim
                    ClmedGeriatra.hisFarmaPresAutoActual = hisFarmaPresAutoActual.Text.Trim
                    ClmedGeriatra.hisFarmaPresAutoPrevia = hisFarmaPresAutoPrevia.Text.Trim
                End If 'fin Antecedentes Genitourinarios
                If txtPestana.Value.Trim >= 3 Then
                    'Historia Farmacologica
                    ClmedGeriatra.hisFarmaPresMed = hisFarmaPresMed.SelectedValue.Trim
                    ClmedGeriatra.hisFarmaPresMedActual = hisFarmaPresMedActual.Text.Trim
                    ClmedGeriatra.hisFarmaPresMedPrevia = hisFarmaPresMedPrevia.Text.Trim
                    ClmedGeriatra.difTrata = difTrata.SelectedValue.Trim
                    ClmedGeriatra.difTrataCausa = difTrataCausa.Text.Trim
                    ClmedGeriatra.difTrataEcono = difTrataEcono.SelectedValue.Trim
                    ClmedGeriatra.difTrataFisico = difTrataFisico.SelectedValue.Trim
                    ClmedGeriatra.difTrataCognitivo = difTrataCognitivo.SelectedValue.Trim
                    ClmedGeriatra.difTrataRAM = difTrataRAM.SelectedValue.Trim
                End If
                If txtPestana.Value.Trim >= 4 Then
                    'antecendentes heredo familiares
                    ClmedGeriatra.heredaHTA = heredaHTA.SelectedValue.Trim
                    ClmedGeriatra.heredaAsma = heredaAsma.SelectedValue.Trim
                    ClmedGeriatra.heredaDemencia = heredaDemencia.SelectedValue.Trim
                    ClmedGeriatra.heredaObesidad = heredaObesidad.SelectedValue.Trim
                    ClmedGeriatra.heredaEpilepsia = heredaEpilepsia.SelectedValue.Trim
                    ClmedGeriatra.heredaDiabetes = heredaDiabetes.SelectedValue.Trim
                    ClmedGeriatra.heredaReumatica = heredaReumatica.SelectedValue.Trim
                    ClmedGeriatra.heredaDepresion = heredaDepresion.SelectedValue.Trim
                    ClmedGeriatra.heredaRenal = heredaRenal.SelectedValue.Trim
                    ClmedGeriatra.heredaTBC = heredaTBC.SelectedValue.Trim
                    ClmedGeriatra.heredaCancer = heredaCancer.SelectedValue.Trim
                    ClmedGeriatra.heredaOtros = heredaOtros.Text.Trim
                End If
                If txtPestana.Value.Trim >= 5 Then
                    'Habitos
                    ClmedGeriatra.habitoFumo = habitoFumo.SelectedValue.Trim
                    ClmedGeriatra.habitoFuma = habitoFuma.SelectedValue.Trim
                    If añosFumando.Text.Trim = "" Then
                        ClmedGeriatra.añosFumando = 0
                    Else
                        ClmedGeriatra.añosFumando = añosFumando.Text.Trim
                    End If
                    If paquetesDia.Text.Trim = "" Then
                        ClmedGeriatra.paquetesDia = 0
                    Else
                        ClmedGeriatra.paquetesDia = paquetesDia.Text.Trim
                    End If
                    ClmedGeriatra.habitoToma = habitoToma.SelectedValue.Trim
                    ClmedGeriatra.frecuenciaTomaDia = frecuenciaTomaDia.SelectedValue.Trim
                    ClmedGeriatra.frecuenciaTomaSemana = frecuenciaTomaSemana.SelectedValue.Trim
                    ClmedGeriatra.frecuenciaTomaMes = frecuenciaTomaMes.SelectedValue.Trim
                    'Historia Psiquiatrica
                    ClmedGeriatra.psiquiDepresion = psiquiDepresion.SelectedValue.Trim
                    ClmedGeriatra.psiquiEnfermedad = psiquiEnfermedad.SelectedValue.Trim
                    ClmedGeriatra.psiquiEnfermedadHospitalizacion = psiquiEnfermedadHospitalizacion.SelectedValue.Trim
                    'Motivo de Consulta y Enfermedad Actual
                    ClmedGeriatra.motivoConsulta = motivoConsulta.Text.Trim
                    'Examen Fisico
                    ClmedGeriatra.tenArterialAltaN = tenArterialAltaN.Text.Trim
                    ClmedGeriatra.tenArterialAltaD = tenArterialAltaD.Text.Trim
                    ClmedGeriatra.tenArterialBajaN = tenArterialBajaN.Text.Trim
                    ClmedGeriatra.tenArterialBajaD = tenArterialBajaD.Text.Trim
                    ClmedGeriatra.tenArterialToma = tenArterialToma.SelectedValue.Trim
                    ClmedGeriatra.temperatura = temperatura.Text.Trim
                    ClmedGeriatra.frecRespiratoria = frecRespiratoria.Text.Trim
                    ClmedGeriatra.frecCardiaca = frecCardiaca.Text.Trim
                    ClmedGeriatra.pulso = pulso.Text.Trim
                    ClmedGeriatra.apariencia = apariencia.SelectedValue.Trim
                    ClmedGeriatra.hidratacion = hidratacion.SelectedValue.Trim
                    ClmedGeriatra.impreDiagnostica = impreDiagnostica.Text.Trim
                    ClmedGeriatra.recomendaciones = recomendaciones.Text.Trim
                End If
                modelo.medicoGeriatras.InsertOnSubmit(ClmedGeriatra)
                modelo.SubmitChanges()
                medicoId.Value = ClmedGeriatra.medicoId.ToString
                If txtContinua.Value.Trim = "Si" Then
                    Msgbox_Web.CreateMessageAlertInUpdatePanel(UpdatePanel1, "alert('Se ha guardado correctamente');")
                Else
                    Msgbox_Web.CreateMessageAlertInUpdatePanel(UpdatePanel1, "alert('Se ha guardado correctamente');window.location = 'encMedicoGeriatra.aspx'")
                End If
            End If
        End If

    End Sub
    Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        Try
            Select Case e.Row.RowType
                Case DataControlRowType.DataRow
                    Dim id As Label = e.Row.FindControl("idParticipante")
                    Dim ctrlEliminar As ImageButton = CType(e.Row.Cells(0).Controls(0), ImageButton)
                    ctrlEliminar.OnClientClick = "fnOculta('" + id.Text.Trim + "','" + e.Row.Cells(5).Text.Trim + "','" + e.Row.Cells(6).Text.Trim + "','" + e.Row.Cells(4).Text.Trim + "');return true;"
                    ctrlEliminar.ToolTip = "Click para ingresar un nuevo registro medico a " + e.Row.Cells(4).Text.Trim.ToUpper
            End Select
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged
        Try
            Dim row As GridViewRow = GridView1.SelectedRow
            Dim id As Label = row.FindControl("idParticipante")
            cargacombos(id.Text.Trim)
            Msgbox_Web.CreateMessageAlertInUpdatePanel(UpdatePanel5, "fnListBox();")
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

    Protected Sub btnBusRapida_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnBusRapida.Click
        SqlDataSource1.FilterExpression = geriatriaClases.fnbusquedaRapida(txtBusquedaRapida.Text.ToString())
        SqlDataSource1.DataBind()
    End Sub
End Class
